package com.wiscamp.ninechapters.problems.adapter.resources.temp;

import cube.ddd.adapter.BaseController;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/")
@Produces(MediaType.APPLICATION_JSON)
@Tag(name = "题库-水平测试")
@Deprecated
public class AssessmentController extends BaseController {

    /*@Autowired
    private AssessmentService assessmentService;*/

    /*@Autowired
    private AlipayService alipayService;*/

    /*@Autowired
    private PaymentsService paymentsService;*/

    // 解决循环引用问题，支付回调移动到这里
    /*@GetMapping("alipay/return")
    @Operation(summary = "支付同步回调")
    @HandleResourceException
    public RestResponse<String> alipayReturn(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        var alipayOrder = alipayService.alipayReturn(request);

        String examCode = "";
        if (Objects.nonNull(alipayOrder)) {
            var payment = paymentsService.getOrderPayment(alipayOrder.getOrderId());
            if (payment == null)
                ExceptionHandler.throwServiceException(null, logger, "NOT_FOUND_ORDERPAYMENT", null);
            payment.setPayTime(LocalDateTime.now());
            examCode = assessmentService.generateAssessmentCodeForUser(payment.getUserId(), payment.getGoodsCode());
            payment.setAssessmentCode(examCode);
            payment.setTransactionNumber(alipayOrder.getTradeNo());
            payment.setAmount(alipayOrder.getAmount());
            paymentsService.updateOrderPayment(payment);
            logger.debug("trade_no:" + alipayOrder.getTradeNo() + "<br/>out_trade_no:" + alipayOrder.getOutTradeNo() + "<br/>total_amount:"+ alipayOrder.getAmount());
        }
        return ResourceHelper.getOkResponse(request, response, examCode);
    }*/

    /*@GetMapping("assessments")
    @Operation(summary = "获取能力测评列表")
    @HandleResourceException
    public RestResponse<Collection<AssessmentPO>> getAssessments(@Context HttpServletRequest request, @Context HttpServletResponse response) {
        return ResourceHelper.getAll(request, response, logger, assessmentService::getAssessments);
    }*/

    /*@GetMapping("assessments/{id}")
    @Operation(summary = "获取能力测评")
    @HandleResourceException
    public RestResponse<AssessmentPO> getAssessment(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("id") long id) {
        return ResourceHelper.getById(request, response, id, logger, assessmentService::getAssessment);
    }*/

    /*@PostMapping("assessments/{id}/start")
    @Operation(summary = "开始能力测评")
    @HandleResourceException
    public RestResponse<Collection<UserAssessmentPO>> startAssessment(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("id") long id, StartAssessmentCommand dto) {
        var result = assessmentService.startAssessment(dto.getUserId(), dto.getAssessmentId(), dto.getProgramIndexes());
        return ResourceHelper.getOkResponse(request, response, result);
    }*/

    /*@PostMapping("users/{userId}/assessment/items")
    @Operation(summary = "获取能力测评项题目")
    @HandleResourceException
    public RestResponse<ClassifiedItem> getUserAssessmentItems(@Context HttpServletRequest request, @Context HttpServletResponse response, UserAssessmentPO userAssessment) {
        var result = assessmentService.getUserAssessmentItems(userAssessment);
        return ResourceHelper.getOkResponse(request, response, result);
    }*/

    /*@PutMapping("users/{userId}/assessment")
    @Operation(summary = "保存完成后的能力测评项信息")
    @HandleResourceException
    public RestResponse<UserAssessmentPO> saveUserAssessment(@Context HttpServletRequest request, @Context HttpServletResponse response, UserAssessmentPO userAssessment) {
        var result = assessmentService.saveUserAssessment(userAssessment);
        return ResourceHelper.getOkResponse(request, response, result);
    }*/

    /*@GetMapping("users/{userId}/assessment/report/{taskId}")
    @Operation(summary = "获取能力测评报告")
    @HandleResourceException
    public RestResponse<AssessmentReport> getAssessmentReport(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("userId") long userId, @PathParam("taskId") long taskId) {
        var result = assessmentService.getAssessmentReport(taskId);
        return ResourceHelper.getOkResponse(request, response, result);
    }*/

    /*@GetMapping("users/{userId}/assessment/actions/use/{code}")
    @Operation(summary = "使用测评代码访问测评")
    @HandleResourceException
    public RestResponse<Boolean> useAssessmentCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("userId") long userId, @PathParam("code") String code) {
        var result = assessmentService.useAssessmentCode(userId, code);
        return ResourceHelper.getOkResponse(request, response, result);
    }*/

    /*@GetMapping("assessments/code/generate/{count}")
    @Operation(summary = "生成测评代码")
    @HandleResourceException
    public RestResponse<Collection<String>> generateAssessmentCode(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("count") int count) {
        var result = assessmentService.generateAssessmentCode(count);
        return ResourceHelper.getOkResponse(request, response, result);
    }*/

    /*@GetMapping("users/{userId}/assessments/actions/generate/{examCode}")
    @Operation(summary = "为用户生成考试码")
    @HandleResourceException
    public RestResponse<String> generateAssessmentCodeForUser(@Context HttpServletRequest request, @Context HttpServletResponse response, @PathParam("userId") long userId, @PathParam("examCode") String examCode) {
        var transactionNumber = request.getHeader("TransactionNumber");
        // validate transaction number
        var result = assessmentService.generateAssessmentCodeForUser(userId, examCode);
        return ResourceHelper.getOkResponse(request, response, result);
    }*/


    /*@PutMapping("users/{userId}/assessment/actions/use")
    @Operation(summary = "使用测评代码访问测评和获取关联任务编号")
    @HandleResourceException
    public RestResponse<Long> useAssessmentCodeForUser(@Context HttpServletRequest request, @Context HttpServletResponse response, UseAssessmentCodeDto useAssessmentCodeDto) {
        var result = assessmentService.useAssessmentCode(useAssessmentCodeDto.getUserId(), useAssessmentCodeDto.getAssessmentCode(), useAssessmentCodeDto.getPoolCode());
        return ResourceHelper.getOkResponse(request, response, result);
    }*/
}
